<template>
	<view class="page">
		<el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">

			<el-tab-pane label="" name="first">
				<el-alert title="因为订单总量未知,因此回传数量并不完全等于订单总量x回传比例.
				当你设置回传比例为50%时,100笔订单并不是一定回传50笔,可能是49也可能是51.数据总量越大,结果越接近此处设置的比例." type="success" :closable="false">
				</el-alert>
				<el-alert
					:title="'当前账户的用户名：'+vk.vuex.get('$user.userInfo.username')+' , 当前账户的代理商ID：'+vk.vuex.get('$user.userInfo._id')"
					type="error" :closable="false">
				</el-alert>
				<el-alert :title="'当前账户的佣金比例：'+vk.vuex.get('$user.userInfo.commission_rate')*100+'%'" type="error"
					:closable="false">
				</el-alert>
				<el-divider></el-divider>

				<!-- <view style="padding: 20px 0;">
					<el-switch v-model="huichuan.newuser" inactive-text="仅回传当日新用户的订单">
					</el-switch>
				</view>

				<view style="padding: 20px 0;" v-if="!huichuan.newuser">
					回传用户
				<vk-data-input-number
							v-model="huichuan.hour_backhaul" width="100px" :precision="0"
							placeholder="请输入数字"></vk-data-input-number>小时内的所有充值
				</view>



				<view class="">
					<el-switch v-model="huichuan.firstorder" inactive-text="仅回传用户的第一笔订单">
					</el-switch>
				</view>



				<el-divider></el-divider>

				<el-radio-group v-model="huichuan.douyinRadio" style="margin-top: 15px;">
					<el-radio :label="0" border>抖音单笔订单回传概率</el-radio>
					<el-radio :label="1" border>循环回传比例</el-radio>
				</el-radio-group>
				<div style="margin-top: 15px;width: 800px;" v-if="!huichuan.douyinRadio">
					<el-input placeholder="请输入内容" v-model="huichuan.douyin" type="number">
						<template slot="prepend">抖音单笔订单回传概率：</template>
						<template slot="append">%</template>
					</el-input>
				</div>

				<view style="margin-top: 15px;width: 800px;" v-else>
					<view style="font-size: 15rpx;color: grey;">当选择【循环回传比例】时,左侧值为上报,右侧值为不上报.
						例:若循环回传比为1:2,就是第1笔上报,第2、3笔不上报,第4笔上报,第5、6笔不上报,如此循环.
						<br/>开启【循环回传比例】时，建议关闭【仅回传当日新用户的订单】，【仅回传用户的第一笔订单】这两项，否则会影响循环比例的准确性</view>
					<view class="" style="margin-top: 15px;width: 800px;display: flex;">
						<el-input placeholder="请输入回传比例" v-model="huichuan.douyin_ReturnRatio" type="number">
							<template slot="prepend">抖音广告循环回传比例：</template>
						</el-input>
						<span style="font-size: 20px;font-weight: 700;margin: 0 15rpx;">:</span>
						<el-input placeholder="请输入不回传比例" v-model="huichuan.douyin_UnReturnRatio" type="number">
						</el-input>
					</view>

				</view>
				<div style="margin-top: 15px;width: 800px; display: flex;flex-wrap: nowrap;">
					<el-input placeholder="请输入内容" v-model="huichuan.douyinMinPrice" type="number">
						<template slot="prepend">【抖音】订单价格低于：</template>
						<template slot="append">元不回传</template>
					</el-input>
					<el-input placeholder="请输入内容" v-model="huichuan.douyinMaxPrice" type="number">
						<template slot="prepend">【抖音】订单价格高于：</template>
						<template slot="append">元不回传</template>
					</el-input>
				</div>
				
				<div style="margin-top: 15px;width: 800px;">
					<el-input placeholder="请输入内容" v-model="huichuan.douyin_url" type="text">
						<template slot="prepend">抖音广告资产化回传URL</template>
					</el-input>
				</div>

				<div style="margin-top: 15px;width: 800px;">
					<el-input placeholder="请输入内容" v-model="huichuan.douyin_token" type="text">
						<template slot="prepend">抖音广告资产化回传TOKEN</template>
					</el-input>
				</div>


				
				

				



				<view style="padding: 2% 20%;">
					<el-button type="primary" @click="saveRebackPercent">保存</el-button>
				</view> -->
			</el-tab-pane>

			<!-- 	<el-tab-pane label="选项卡2" name="second">
				备用选项卡2
			</el-tab-pane>

			<el-tab-pane label="选项卡3" name="third">
				备用选项卡3
			</el-tab-pane> -->

		</el-tabs>
	</view>
</template>

<script>
	var that; // 当前页面对象
	var vk = uni.vk; // vk实例
	const db = uniCloud.database();

	export default {
		data() {
			return {

				activeName: 'first',
			};
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			that = this;
			vk = that.vk;
			that.options = options;
		},
		async onShow() {
			let user_role = vk.vuex.get('$user.userInfo.role');
			if (user_role.includes("admin")) {
				this.$alert('这是代理商页面，管理员请勿操作。如需设置回传比例，请先创建一个代理商账号，登录代理商账号设置。', '提示', {
					confirmButtonText: '确定',
					callback: action => {
						uni.navigateTo({
							url: "/pages/admin/dlsgl/agent"
						})
						return;
					}
				});
			}
			this.loadData()
		},
		onReady() {

		},
		methods: {


		}
	};
</script>

<style>
	.page {
		padding-top: 20px;
	}

	.formview {
		width: 40%;
	}
</style>